// wigets/business/video/video.js
import {
  api,
  util,
  storage
} from '../../../js/util'

Component({

  /**
   * 组件的属性列表
   */
  properties: {
    src: { // 视频链接
      type: String,
      value: '',
    },
    poster: { // 封面图
      type: String,
      value: ''
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
    imgDomain: api.imgDomain,
    videoDomain: api.videoDomain,
    enableOss: api.enableOss,
    isPlay: false,
  },

  /**
   * 组件的方法列表
   */
  methods: {
    playVideo () {
      let that = this
      this.setData({
        isPlay: true
      }, function () {
        let query = that.createSelectorQuery()
        query.select('#video').fields({
          context: true,
          node: true
        }).exec((res) => {
          let video = res[0].context
          video.play()
        })
      })
    },
  }
})